package vn.gg.parchessi;

import java.net.InetSocketAddress;

import org.apache.mina.core.service.IoAcceptor;
import org.apache.mina.filter.codec.ProtocolCodecFilter;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;

import vn.gg.network.Message;
import vn.gg.network.MinaInput;
import vn.gg.network.ServerCodecFactory;
import vn.gg.util.Log;

public class Main {
	
	private static final String TAG = "Main";
	private static final int PORT = 8888;
	

    public static void main(String[] args) throws Exception {
        IoAcceptor acceptor = new NioSocketAcceptor();
//        acceptor.getFilterChain().addLast("logger", new LoggingFilter());
        acceptor.getFilterChain().addLast("codec",
                new ProtocolCodecFilter(new ServerCodecFactory()));
        MinaInput mi = new MinaInput();
//        mi.setMessageHandler(new GlobalMessageHandler());
        acceptor.setHandler(mi);
        acceptor.bind(new InetSocketAddress(PORT));
        System.out.print("MinaTimeServer start in port:" + PORT);
//        Message m = new Message("Truong", "Bich");
//        Log.log(TAG, m.toJson());
    }
}
